﻿#ifndef BASENETWORKACCESSMANAGER_H
#define BASENETWORKACCESSMANAGER_H

#include <QtNetwork>

const static QString BASE_URL_RELEASE = "http://122.51.166.114:8080/StoremsServer/";
const static QString BASE_URL_DEBUG = "http://localhost:8080/";
const static QString BASE_URL = BASE_URL_DEBUG;

class BaseNetworkAccessManager : public QNetworkAccessManager
{
    Q_OBJECT
public:
    explicit BaseNetworkAccessManager(QObject *parent = nullptr);

    enum RequestState{
        SUCCESS,
        FAILED
    };
    Q_ENUM(RequestState)

    void doGet(const QString url);

    void doPost(const QString url, const QByteArray data);

signals:
    void onSuccess(QString message);

    void onSuccessWithData(QString message, QJsonObject data);

    void onFailed(QString message);

public slots:

private:
    QNetworkReply *reply;
};

#endif // BASENETWORKACCESSMANAGER_H
